<style scoped xmlns="http://www.w3.org/1999/html">
    /*量体师页面*/
    .echarts-item {
        width: 500px;
        height: 400px;
        display: inline-block;
    }
    /*头部*/
    Button .echarts-item{
        margin-right: 5px;
        color: #37b3b3;
    }
    Button .pieDivBtn{
        margin-right: 5px;
        color: #3398ff;
    }
    /*新增量体师信息*/
    .quantitativeAdd .ivu-input-wrapper{width: 90%}
    .quantitativeAdd .date .ivu-date-picker{width: 90%;display: inline-block;}
    /*搜索结束*/
    .details .ivu-row .ivu-col .ivu-form-item{margin-bottom: 0px;}
    .details .content{padding: 3px 30px; box-shadow: 0px 0px 3px 0px #f0f0f0;}
</style>
<template>
    <div class="console-product">
        <Row class="position">
            <i-col :xs="12" :sm="10" :md="8" :lg="6" >
                <div class="ivu-breadcrumb pos">
                    <span class="ivu-breadcrumb-item-link">当前位置：</span>
                    <span class="ivu-breadcrumb-item-link">业务中心</span>
                    <span class="ivu-breadcrumb-item-separator">/</span>
                    <span class="ivu-breadcrumb-item-link">量体师</span>
                </div>
            </i-col>
            <i-col class="fr">
                <span>
                    <Button @click="quantitativeInformation"><Icon class="addLtsdnBtn" style="color: #37b3b3;" type="ios-plus-outline"></Icon> 新增</Button>
                    <Modal class-name="popup" v-model="ltsdnBeanModel" width="337" :mask-closable="false" @on-cancel="close('ltsdnBean')">
                        <p slot="header" style="color: #eeebeb"  v-drag>
                            <span  v-if="isAdd">添加量体师信息</span>
                            <span  v-if="isEdit">编辑量体师信息</span>
                        </p>
                        <Form ref="ltsdnBean" class="quantitativeAdd" :rules="ruleAdd" :model="ltsdnBean" label-position="left" :label-width="80">
                            <Row>
                                <i-col span="24">
                                    <Form-item label="公司名称:" prop="gsmc">
                                        <Input v-model="ltsdnBean.gsmc" placeholder="请输入..."></Input>
                                    </Form-item>
                                </i-col>
                            </Row>
                            <Row>
                                <i-col span="24">
                                    <Form-item label="订单号前缀:" prop="ddhqz">
                                        <Input v-model="ltsdnBean.ddhqz" placeholder="请输入..."></Input>
                                    </Form-item>
                                </i-col>
                            </Row>
                            <Row>
                                <i-col span="24">
                                    <Form-item label="姓名:" prop="name">
                                        <Input v-model="ltsdnBean.name" placeholder="请输入..."></Input>
                                    </Form-item>
                                </i-col>
                            </Row>
                            <Row v-if="isEdit" >
                                <i-col span="24" >
                                    <Form-item label="分数:" prop="score" >
                                        <Input v-model="ltsdnBean.score" placeholder="请输入..."></Input>
                                    </Form-item>
                                </i-col>
                            </Row>
                            <Row>
                                <i-col span="24">
                                    <Form-item label="资格证编号:" prop="zgzbh">
                                        <Input v-model="ltsdnBean.zgzbh" placeholder="请输入..."></Input>
                                    </Form-item>
                                </i-col>
                            </Row>
                            <Row>
                                <i-col span="24">
                                    <Form-item label="发放日期:" prop="ffrq" class="date">
                                        <Date-picker type="date" v-model="ltsdnBean.ffrq" placeholder="发放日期"></Date-picker>
                                    </Form-item>
                                </i-col>
                            </Row>
                            <Row>
                                <i-col span="24">
                                    <Form-item label="发放人员:" prop="ffry">
                                        <Input v-model="ltsdnBean.ffry" placeholder="请输入..."></Input>
                                    </Form-item>
                                </i-col>
                            </Row>
                        </Form>
                        <div slot="footer">
                            <div class="footer">
                                <Button v-if="isAdd" class="save" :loading="modal_loading" @click="saveAdd('ltsdnBean')">保存</Button>
                                <Button v-if="isEdit" class="save" :loading="modal_loading" @click="saveEdit('ltsdnBean')">保存</Button>
                            </div>
                        </div>
                    </Modal>
                </span>
                <span>
                    <Button @click="openPieDiv"><i class="iconfont" style="color: #3398ff;">&#xe600;</i> 数据比对</Button>
                    <Modal class-name="popup" v-model="pieModal" width="700" :mask-closable="false" @on-cancel="cancelPie" >
                        <p slot="header" style="color: #eeebeb" v-drag>量体人员数据对比</p>
                        <div class="content" style="height: 550px">
                            <Form :model="pieDivForm" ref="pieDivForm" label-position="left" inline style="text-align: center">
                                <Form-item label="日期：" :label-width="45">
                                    <Date-picker type="daterange" v-model="pieDivForm.date"  :options="creatDate0ptions" placeholder="选择日期" style="width: 200px"></Date-picker>
                                </Form-item>
                                <Button @click="searchPie" class="search">查询</Button>
                            </Form>
                            <div class="echarts">
                                <div class="echarts-item">
                                    <IEcharts style="width: 500px;height: 550px;" :option="pie"></IEcharts>
                                </div>
                            </div>
                        </div>
                        <p slot="footer"></p>
                    </Modal>
                </span>
                <Modal class="detailsbody" class-name="popup" v-model="detailsModal" width="498" :mask-closable="false" @on-cancel="closeDetails">
                    <p slot="header" style="color: #eeebeb"  v-drag>
                        <span>量体人员详情</span>
                    </p>
                    <div class="details">
                        <Form :model="detailsForm" ref="detailsCard" label-position="left" :label-width="90"  inline>
                            <Row class="content" style="padding-top: 8px;">
                                <i-col span="12">
                                    <Form-item label="公司名称：">
                                        <span>{{detailsForm.gsmc}}</span>
                                    </Form-item>
                                </i-col>
                                <i-col span="12">
                                    <Form-item label="发放日期：">
                                        <span>{{detailsForm.ffrq}}</span>
                                    </Form-item>
                                </i-col>
                            </Row>
                            <Row class="content">
                                <i-col span="12">
                                    <Form-item label="订单号前缀：">
                                        <span>{{detailsForm.ddhqz}}</span>
                                    </Form-item>
                                </i-col>
                                <i-col span="12">
                                    <Form-item label="发放人员：">
                                        <span>{{detailsForm.ffry}}</span>
                                    </Form-item>
                                </i-col>
                            </Row>
                            <Row class="content">
                                <i-col span="12">
                                    <Form-item label="姓名：">
                                        <span>{{detailsForm.name}}</span>
                                    </Form-item>
                                </i-col>
                                <i-col span="12">
                                    <Form-item label="分数：">
                                        <span>{{detailsForm.score}}</span>
                                    </Form-item>
                                </i-col>
                            </Row>
                            <Row class="content">
                                <i-col span="12">
                                    <Form-item label="资格证编号：">
                                        <span>{{detailsForm.zgzbh}}</span>
                                    </Form-item>
                                </i-col>
                                <i-col span="12">
                                    <Form-item label="审核状态：">
                                        <span>{{detailsForm.isclose == '1' ? '审核' : '未审核'}}</span>
                                    </Form-item>
                                </i-col>
                            </Row>
                            <Row class="content" style="padding-bottom: 8px;">
                                <i-col span="12">
                                    <Form-item label="创建人：">
                                        <span>{{detailsForm.createby}}</span>
                                    </Form-item>
                                </i-col>
                                <i-col span="12">
                                    <Form-item label="创建时间：">
                                        <span>{{detailsForm.createtime}}</span>
                                    </Form-item>
                                </i-col>
                            </Row>
                        </Form>
                    </div>
                    <div slot="footer"></div>
                </Modal>
            </i-col>
        </Row>
        <div class="console-product-contcent ltdnlistPage" id="contcentHeight" :style="{height:height +'px'}">
            <Form class="searchform" ref="ltsdnBeanFrom" :model="ltsdnBeanFrom" inline>
                <Form-item label="状态:" :label-width="35" style="width: 120px">
                    <Select v-model="ltsdnBeanFrom.isclose">
                        <Option v-for="item in iscloseList" :value="item.value" :key="item">{{ item.label }}</Option>
                    </Select>
                </Form-item>
                <Form-item label="公司名称:" :label-width="65" style="width: 190px">
                    <Input v-model="ltsdnBeanFrom.gsmc" placeholder="请输入" @on-enter="btnSearch"></Input>
                </Form-item>
                <Form-item label="量体师姓名:" :label-width="80" style="width: 205px">
                    <Input v-model="ltsdnBeanFrom.name" placeholder="请输入" @on-enter="btnSearch"></Input>
                </Form-item>
                <Form-item label="资格证编号:" :label-width="80" style="width: 205px">
                    <Input v-model="ltsdnBeanFrom.zgzbh" placeholder="请输入" @on-enter="btnSearch"></Input>
                </Form-item>
                <Form-item>
                    <Button class="search" @click="btnSearch">搜索</Button>
                </Form-item>
            </Form>
            <Modal v-model="delModal" class-name="delect" width="250" :loading="delLoading" @on-cancel="delCancel" :mask-closable="false" >
                <p slot="header" style="color: #eeebeb" v-drag>
                    <span>提示框</span>
                </p>
                <p class="delbody">
                    <i class="iconfont" style="color: #f76165;font-size: 16px;">&#xe615</i>&nbsp;&nbsp;确认删除？
                </p>
                <div slot="footer">
                    <div class="footer">
                        <Button  class="save" :loading="delLoading" @click="delOK">确认</Button>
                        <Button class="clear" @click="delCancel">取消</Button>
                    </div>
                </div>
            </Modal>
            <Loading v-if="spinShow"></Loading>
            <Table v-if="tableShow" @on-selection-change="selectChange" ref="quantumMasterTable" stripe border :columns="quantumMasterColumns" :data="quantumMasterData"></Table>
        </div>
        <Row style="background-color: #ffffff;margin-top: 1px;">
            <Col>
            <div v-if="tableShow" class="tablepage clearfix">
                <div class="fl">
                    <span>共</span>
                    <span class="num">{{total}}</span>
                    <span>条记录</span>
                    <span>{{currentPage}}/{{pageTotal}}页</span>
                </div>
                <div class="fr">
                    <Page :total="total" :page-size="pageSize" :current="currentPage" placement="top" show-elevator show-sizer @on-change="changePage" @on-page-size-change="changeSize"></Page>
                </div>
            </div>
            </Col>
        </Row>
    </div>
</template>
<script>
    import Loading from '../../components/loading';
    import IEcharts from 'vue-echarts-v3/src/full.vue';
    export default {
        //所需子组件
        components: {Loading,IEcharts},
        data () {
            const scoreZH = (rule, value, callback) => {
                var re = /^[0-9]*[1-9][0-9]*$/;
                if(value != "" && value != null){
                    if (re.test(value)) {
                        callback();
                    } else {
                        callback(new Error('请输入整数'));
                    }
                }else{
                    callback();
                }

            };
            const validatezgzbh = (rule, value, callback) => {
                var re = /^[0-9A-Za-z]{0,10}$/;
                if (re.test(value)) {
                    callback();
                } else {
                    callback(new Error('数字加字母最多10位'));
                }
            };
            const validateddhqz = (rule, value, callback) => {
                var re = /^[0-9A-Za-z]{0,8}$/;
                if (re.test(value)) {
                    callback();
                } else {
                    callback(new Error('数字加字母最多8位'));
                }
            };
            const validatedate = (rule, value, callback) => {
                if (value != "" && value != null) {
                    callback();
                } else {
                    callback(new Error('发放日期不能为空'));
                }
            };

            return {
                pie: {
                    title: {
                        text: '',
                        x: 'center'
                    },
                    tooltip: {
                        trigger: 'item',
                        formatter: "{a} <br/>{b} : {c} ({d}%)"
                    },
                    series: [],
                    itemStyle: {
                        emphasis: {
                            shadowBlur: 10,
                            shadowOffsetX: 0,
                            shadowColor: 'rgba(0, 0, 0, 0.5)'
                        }
                    }
                },//数据的对比饼状图
                pieModal: false,
                total:0,//总条数
                currentPage:1,//当前页
                pageTotal:1,//总页数
                pageSize:10,//默认每页显示数量
                height:1000,//表单高度
                spinShow: true,//加载层，默认显示
                tableShow: false,//表格层，默认隐藏
                modal_loading: false,
                isAdd:false,//添加
                isEdit:false,//编辑
                ltsdnBeanModel:false,
                detailsModal:false,//详情
                delModal:false,
                delLoading:false,//删除
                delId:'',//删除id
                zgzbh:"",//选择的量体师
                ltsdnBeanFrom:{//量体师查询条件
                    isclose:'',
                    gsmc:'',
                    name:'',
                    zgzbh:''
                },
                iscloseList:[
                    {
                        value: '',
                        label: '请选择'
                    },
                    {
                        value: '1',
                        label: '审核'
                    },
                    {
                        value: '0',
                        label: '未审核'
                    }
                ],
                //量体师格式
                quantumMasterColumns:[
                    {
                        width:'4%',
                        type:'selection',
                        align:'center'
                    },
                    {
                        width:'4%',
                        title: '审核',
                        key: 'isclose',
                        render: (h, params) => {
                            return h('div', [
                                params.row.isclose == 0 ?
                                    h('Tooltip', {
                                        props: {
                                            content: '未审核',
                                            placement:"bottom-start"
                                        }
                                    }, [h('i',
                                        {
                                            class:'iconfont icon-shape2',
                                            style:{
                                                cursor:'pointer',
                                                color: '#333'
                                            },
                                            on: {
                                                click: () => {
                                                    this.toggleFav(params.row)
                                                }
                                            }
                                        })])
                                    :
                                    h('Tooltip', {
                                        props: {
                                            content: '审核',
                                            placement:"bottom-start"
                                        }
                                    }, [h('i',
                                        {
                                            class:'iconfont icon-shape2',
                                            style:{
                                                cursor:'pointer',
                                                color: '#37b3b3'
                                            },
                                            on: {
                                                click: () => {
                                                    this.toggleFav(params.row)
                                                }
                                            }
                                        })])
                            ]);
                        }
                    },
                    {
                        width:'18%',
                        title: '公司名称',
                        key: 'gsmc',
                        render: (h, params) => {
                            return h('Tooltip', {
                                props: {
                                    content: params.row.gsmc,
                                    placement:"bottom-start"
                                }
                            }, [h('span', params.row.gsmc)]);
                        }
                    },
                    {
                        width:'6%',
                        title: '分数',
                        key: 'score',
                        render: (h, params) => {
                            return h('Tooltip', {
                                props: {
                                    content: params.row.score,
                                    placement:"bottom-start"
                                }
                            }, [h('span', params.row.score)]);
                        }
                    },
                    {
                        width:'6%',
                        title: '姓名',
                        key: 'name',
                        render: (h, params) => {
                            return h('Tooltip', {
                                props: {
                                    content: params.row.name,
                                    placement:"bottom-start"
                                }
                            }, [h('span', params.row.name)]);
                        }
                    },
                    {
                        width:'10%',
                        title: '资格证编号',
                        key: 'zgzbh',
                        render: (h, params) => {
                            return h('Tooltip', {
                                props: {
                                    content: params.row.zgzbh,
                                    placement:"bottom-start"
                                }
                            }, [h('span', params.row.zgzbh)]);
                        }
                    },
                    {
                        width:'8%',
                        title: '发放日期',
                        key: 'ffrq',
                        render: (h, params) => {
                            return h('Tooltip', {
                                props: {
                                    content: params.row.ffrq,
                                    placement:"bottom-start"
                                }
                            }, [h('span', params.row.ffrq)]);
                        }
                    },
                    {
                        width:'8%',
                        title: '发放人员',
                        key: 'ffry',
                        render: (h, params) => {
                            return h('Tooltip', {
                                props: {
                                    content: params.row.ffry,
                                    placement:"bottom-start"
                                }
                            }, [h('span', params.row.ffry)]);
                        }
                    },
                    {
                        width:'8%',
                        title: '创建人',
                        key: 'createby',
                        render: (h, params) => {
                            return h('Tooltip', {
                                props: {
                                    content: params.row.createby,
                                    placement:"bottom-start"
                                }
                            }, [h('span', params.row.createby)]);
                        }
                    },
                    {
                        width:'14%',
                        title: '创建时间',
                        key: 'createtime',
                        render: (h, params) => {
                            return h('Tooltip', {
                                props: {
                                    content: params.row.createtime,
                                    placement:"bottom-start"
                                }
                            }, [h('span', params.row.createtime)]);
                        }
                    },
                    {
                        width:'14%',
                        title: '操作',
                        key: 'id',
                        render: (h, params) => {
                            return h('div', [
                                h('Button',
                                    {
                                        class:"blue",
                                        on: {
                                            click: () => {
                                                this.editQuantumMaster(params.row.id)
                                            }
                                        }
                                    }, [
                                        h('i', {
                                            class : 'iconfont icon-bianji'
                                        }),
                                        h("span",'编辑')
                                    ]),
                                h('Button',
                                    {
                                        class:"red",
                                        on: {
                                            click: () => {
                                                this.removeQuantumMaster(params.row.id)
                                            }
                                        }
                                    }, [
                                        h('i', {
                                            class : 'iconfont icon-shanchu'
                                        }),
                                        h("span",'删除')
                                    ]),
                                h('Button',
                                    {
                                        class:"green",
                                        on: {
                                            click: () => {
                                                this.detailsQuantumMaster(params.row.id)
                                            }
                                        }
                                    }, [
                                        h('i', {
                                            class : 'iconfont icon-bianji'
                                        }),
                                        h("span",'详情')
                                    ])
                            ]);
                        }
                    }
                ],
                quantumMasterData:[],
                //新增量体师信息
                ltsdnBean:{
                    id:"",
                    gsmc:'',
                    score:'',
                    ddhqz:'',
                    name:'',
                    zgzbh:'',
                    ffrq:'',
                    ffry:''
                },
                //新增量体师验证
                ruleAdd:{
                    gsmc:[
                        {required:true,message:'公司名称不能为空',trigger:'blur'},
                        { type: 'string', max: 100, message: '公司名称不能大于100位', trigger: 'blur' }
                    ],
                    ddhqz:[
                        {type: 'string', validator: validateddhqz, trigger: 'blur'}
                    ],
                    name:[
                        {required:true,message:'量体师姓名不能为空',trigger:'blur'},
                        { type: 'string', max: 50, message: '量体师姓名不能大于50位', trigger: 'blur' }
                    ],
                    score:[
                        {type: 'string', validator: scoreZH, trigger: 'blur'},
                        { type: 'string', max: 9, message: '分数不能大于9位', trigger: 'blur' }
                    ],
                    zgzbh:[
                        {required:true,message:'资格证编号不能为空',trigger:'blur'},
                        {type: 'string', validator: validatezgzbh, trigger: 'blur'}
                    ],
                    ffrq:[
                        {required:true, validator: validatedate,trigger:'change'}
                    ],
                    ffry:[
                        { type: 'string', max: 50, message: '发放人员不能大于50位', trigger: 'blur' }
                    ]
                },
                //量体师详情
                detailsForm:{
                    gsmc:'',
                    ddhqz:'',
                    name:'',
                    zgzbh:'',
                    ffrq:'',
                    ffry:'',
                    isClose:'',
                    score:'',
                    createby:'',
                    createtime:''
                },
                pieDivForm:{
                    date:[new Date().getTime() - 3600 * 1000 * 24 * 7,new Date()]
                },
                creatDate0ptions: {
                    shortcuts: [
                        {
                            text: '最近一周',
                            value () {
                                const end = new Date();
                                const start = new Date();
                                start.setTime(start.getTime() - 3600 * 1000 * 24 * 7);
                                return [start, end];
                            }
                        },
                        {
                            text: '最近一个月',
                            value () {
                                const end = new Date();
                                const start = new Date();
                                start.setTime(start.getTime() - 3600 * 1000 * 24 * 30);
                                return [start, end];
                            }
                        },
                        {
                            text: '最近三个月',
                            value () {
                                const end = new Date();
                                const start = new Date();
                                start.setTime(start.getTime() - 3600 * 1000 * 24 * 90);
                                return [start, end];
                            }
                        }
                    ]
                }
            }
        },
        created:function(){
            var width = window.innerWidth;
            if(width >1600){
                this.height=window.innerHeight-200;
            }else if(width > 1440 && width <=1600){
                this.height=window.innerHeight-180;
            }else if(width > 1366 && width <=1440){
                this.height=window.innerHeight-172;
            }else if(width > 1280 && width <=1366){
                this.height=window.innerHeight-166;
            }else if(width > 1024 && width <=1280){
                this.height=window.innerHeight-162;
            }else{
                this.height=window.innerHeight-151;
            }
            if(window.innerWidth > 1600){
                this.pageSize = 20;
            }
            this.quantumMasterData = this.quantumMasterTableData(this.ltsdnBeanFrom,this.currentPage,this.pageSize);
        },
        mounted() {
        },
        methods: {
            //查询物流数据，条件，当前页，每页显示多少条
            quantumMasterTableData (formData,currentPage,pageSize) {
                this.spinShow=true;
                this.tableShow = false;
                var isclose = formData.isclose;//状态
                var gsmc = formData.gsmc;//公司名称
                var name = formData.name;//量体师姓名
                var zgzbh = formData.zgzbh;//资格证编号
                let data = {
                    params: {
                        pageIndex : currentPage,
                        pageSize : pageSize,
                        isclose : isclose,
                        gsmc : gsmc,
                        name : name,
                        zgzbh : zgzbh
                    }
                }
                axios.get('/cltsdns',data).then(res => {
                    this.total=res.data.total;
                    this.pageTotal=Math.ceil(res.data.total / pageSize);
                    this.quantumMasterData = res.data.data;
                    this.spinShow=false;
                    this.tableShow = true;
                }).catch(err =>{
                })
            },
            //条件查询
            btnSearch(){
                this.currentPage=1;
                this.quantumMasterData = this.quantumMasterTableData(this.ltsdnBeanFrom,this.currentPage,this.pageSize);
            },
            //改变页数
            changePage: function (page) {
                this.currentPage=page;
                this.quantumMasterData = this.quantumMasterTableData(this.ltsdnBeanFrom,this.currentPage,this.pageSize);
            },
            //改变每页显示多少条
            changeSize: function (pageSize) {
                this.currentPage=1;
                this.pageSize = pageSize;
                this.pageTotal=Math.ceil(this.total / this.pageSize);
                this.quantumMasterData = this.quantumMasterTableData(this.ltsdnBeanFrom,this.currentPage,this.pageSize);
            },
            //新增量体师信息
            quantitativeInformation(){
                this.isAdd = true;//新增title和保存
                this.ltsdnBeanModel = true;//新增
            },
            //根据ID编辑量体师
            editQuantumMaster(column) {
                this.isEdit = true;
                axios.get('/cltsdns/'+column).then(res => {
                    this.ltsdnBeanModel = true;//新增
                    this.ltsdnBean = res.data;
                    this.ltsdnBean.score= this.ltsdnBean.score.toString();
                }).catch(err =>{
                });
            },
            //根据ID删除量体师信息
            removeQuantumMaster(column){
                this.delModal=true;
                this.delId = column;
            },
            delOK(){
                this.delLoading = true;
                axios.delete('/cltsdns/'+this.delId).then(res => {
                    this.delLoading = false;
                    this.delModal=false;
                    this.$Message.success('删除成功');
                    this.quantumMasterData = this.quantumMasterTableData(this.ltsdnBeanFrom,this.currentPage,this.pageSize);
                }).catch(err =>{
                });
            },
            delCancel() {
                this.delModal=false;
                this.delId = '';
            },
            //根据ID查看详情量体师
            detailsQuantumMaster(column) {
                axios.get('/cltsdns/'+column).then(res => {
                    this.detailsModal = true;//详情
                    this.detailsForm = res.data;
                }).catch(err =>{
                });
            },
            //新增保存
            saveAdd(name){
                this.$refs[name].validate((valid) => {
                    if(valid){
                        var date = "";
                        if(this.ltsdnBean.ffrq != ""){
                            var time = new Date(this.ltsdnBean.ffrq).getTime();
                            date = new Date(time).format("yyyy-MM-dd");
                        }
                        let data = {
                            gsmc : this.ltsdnBean.gsmc,
                            ddhqz : this.ltsdnBean.ddhqz,
                            name : this.ltsdnBean.name,
                            zgzbh : this.ltsdnBean.zgzbh,
                            ffrq : date,
                            ffry : this.ltsdnBean.ffry

                        }
                        if(this.ltsdnBean.zgzbh.length > 10){
                            this.$Message.error('资格证编号的长度不能超过10');
                        }else {
                            axios.post('/cltsdns', data).then(res => {
                                this.modal_loading = false;
                                this.ltsdnBeanModel = false;
                                this.isAdd = false;//新增title和保存
                                this.$Message.success('添加成功');
                                this.$refs[name].resetFields();
                                this.quantumMasterData = this.quantumMasterTableData(this.ltsdnBeanFrom,this.currentPage,this.pageSize);
                            }).catch(err =>{
                                this.$Message.error({content: err,duration: 0,closable:true});
                            });
                        }

                    }else{
                        this.modal_loading = false;
                    }
                })
            },
            //编辑保存
            saveEdit(name) {
                this.$refs[name].validate((valid) => {
                    if(valid){
                        var date = "";
                        if(this.ltsdnBean.ffrq != ""){
                            var time = new Date(this.ltsdnBean.ffrq).getTime();
                            date = new Date(time).format("yyyy-MM-dd");
                        }
                        let data = {
                            id : this.ltsdnBean.id,
                            score:this.ltsdnBean.score,
                            gsmc : this.ltsdnBean.gsmc,
                            ddhqz : this.ltsdnBean.ddhqz,
                            name : this.ltsdnBean.name,
                            zgzbh : this.ltsdnBean.zgzbh,
                            ffrq : date,
                            ffry : this.ltsdnBean.ffry

                        };
                        if(this.ltsdnBean.zgzbh.length > 10){
                            this.$Message.error('资格证编号的长度不能超过10');
                        }else{
                            axios.put('/cltsdns', data).then(res => {
                                this.modal_loading = false;
                                this.ltsdnBeanModel = false;
                                this.isEdit = false;//新增title和保存
                                this.$Message.success('编辑成功');
                                this.$refs[name].resetFields();
                                this.quantumMasterData = this.quantumMasterTableData(this.ltsdnBeanFrom,this.currentPage,this.pageSize);

                            }).catch(err =>{
                                this.$Message.error({content: err,duration: 0,closable:true});
                            });
                        }

                    }else{
                        this.modal_loading = false;
                    }
                })
            },
            //关闭重置
            close(name){
                this.$refs[name].resetFields();
                this.isAdd = false;//新增title和保存
                this.isEdit = false;//编辑title和保存
                this.modal_loading = false;
                this.ltsdnBeanModel = false;//新增
            },
            //详情关闭重置信息
            closeDetails(){
                this.detailsForm={
                    gsmc:'',
                    ddhqz:'',
                    name:'',
                    zgzbh:'',
                    ffrq:'',
                    ffry:'',
                    isClose:'',
                    score:'',
                    createby:'',
                    createtime:''
                };
                this.detailsModal = false;
            },
            //更改量体师审核状态
            toggleFav (row) {
                row.isclose = row.isclose == '0' ?'1' : '0';
                axios.put('/cltsdnReview', row).then(res => {
                    this.quantumMasterData[row._index].isclose = this.quantumMasterData[row._index].isclose == '0' ?'1' : '0';
                }).catch(err =>{
                });
            },
            //单选 全选
            selectChange(selection) {
                var zgzbhList = "";
                for(var index in selection){
                    zgzbhList += selection[index].zgzbh + ",";
                }
                if(zgzbhList.length > 0) {
                    zgzbhList = zgzbhList.substring(0, zgzbhList.length-1);
                }
                this.zgzbh = zgzbhList;
            },
            //打开数据对比
            openPieDiv(){
                if(this.zgzbh == ""){
                    this.$Message.error('请至少选择一个量体师!');
                }else{
                    this.pieModal = true;
                }
            },
            //关闭数据对比
            cancelPie(){
                this.pie.title.text = "";
                this.pie.series = [
                    {
                        name:'数量',
                        type:'pie',
                        selectedMode: 'single',
                        radius: [0, '40%'],//饼图的半径，数组的第一项是内半径，第二项是外半径。

                        label: {
                            normal: {
                                position: 'inner'
                            }
                        },
                        labelLine: {
                            normal: {
                                show: false
                            }
                        },
                        data:[]
                    },
                    {
                        name:'数量',
                        type:'pie',
                        radius: ['40%', '55%'],
                        data:[]
                    }
                ];
                this.pieDivForm.date=[new Date().getTime() - 3600 * 1000 * 24 * 7,new Date()];
                this.pieModal = false;
            },
            //查询数据
            searchPie(){
                var zgzbh = this.zgzbh;
                //var zgzbh = "KF20150496,201400921,201300277";
                var startDate = "";
                var endDate = "";
                if(this.pieDivForm.date.length != 0){
                    var fromDateTime = (new Date(this.pieDivForm.date[0])).getTime();
                    startDate = new Date(fromDateTime).format("yyyy-MM-dd");
                    var toDateTime = (new Date(this.pieDivForm.date[1])).getTime();
                    endDate = new Date(toDateTime).format("yyyy-MM-dd");
                    axios.get('/cltsdnCompare/'+zgzbh+"/"+startDate+"/"+endDate).then(res => {
                        if(res.data.length != 0){
                            this.pie.title.text = "销量与试衣反馈";
                            var fksl = 0;
                            var zsl = 0;
                            var arr = [];
                            for(var i = 0;i<res.data.length;i++){
                                fksl += res.data[i].syfkCount;
                                zsl += res.data[i].sales;
                                arr.push({value:res.data[i].sales, name:res.data[i].name});
                            }
                            for(var i = 0;i<res.data.length;i++){
                                arr.push({value:res.data[i].syfkCount, name:res.data[i].name});
                            }
                            var arr2 = [{value:fksl, name:'反馈数量'},{value:zsl, name:'总数量'}];
                            this.pie.series = [
                                {
                                    name:'数量',
                                    type:'pie',
                                    selectedMode: 'single',
                                    radius: [0, '40%'],//饼图的半径，数组的第一项是内半径，第二项是外半径。

                                    label: {
                                        normal: {
                                            position: 'inner'
                                        }
                                    },
                                    labelLine: {
                                        normal: {
                                            show: false
                                        }
                                    },
                                    data:arr2
                                },
                                {
                                    name:'数量',
                                    type:'pie',
                                    radius: ['40%', '55%'],
                                    data:arr
                                }
                            ]
                        }else{
                            this.pie.title.text = "查询的量体师没有数据";
                            this.pie.series = [
                                {
                                    name:'数量',
                                    type:'pie',
                                    selectedMode: 'single',
                                    radius: [0, '40%'],//饼图的半径，数组的第一项是内半径，第二项是外半径。

                                    label: {
                                        normal: {
                                            position: 'inner'
                                        }
                                    },
                                    labelLine: {
                                        normal: {
                                            show: false
                                        }
                                    },
                                    data:[]
                                },
                                {
                                    name:'数量',
                                    type:'pie',
                                    radius: ['40%', '55%'],
                                    data:[]
                                }
                            ];
                        }
                    }).catch(err =>{
                    })
                }else{
                    this.$Message.error('请选择日期!');
                    this.pie.title.text = "";
                    this.pie.series = [
                        {
                            name:'数量',
                            type:'pie',
                            selectedMode: 'single',
                            radius: [0, '40%'],//饼图的半径，数组的第一项是内半径，第二项是外半径。

                            label: {
                                normal: {
                                    position: 'inner'
                                }
                            },
                            labelLine: {
                                normal: {
                                    show: false
                                }
                            },
                            data:[]
                        },
                        {
                            name:'数量',
                            type:'pie',
                            radius: ['40%', '55%'],
                            data:[]
                        }
                    ];
                }
                }
            }
    }
</script>